<script>
// #ifdef MP
	let livePlayer = requirePlugin('live-player-plugin')
	
// #endif
export default {
	globalData: {
	    is_true:true,
		/** 代理客户id */
	},
	onLaunch: function() {
		console.log('App Launch');
		let that = this
	},
	onShow(options) {
		// 分享卡片入口场景才调用getShareParams接口获取以下参数
		// #ifdef MP
		console.log(options)
		// this.tui.toast(JSON.stringify(options))
		let that = this
		that.tui.autoUpdate()
		if(options.path=="__plugin__/wx2b03c6e691cd7370/pages/live-player-plugin"&&options.scene == 1089){
			that.tui.TongjiLive(1, uni.getStorageSync('room_id'))
		}
		if(options.path=="__plugin__/wx2b03c6e691cd7370/pages/live-player-plugin"&&options.scene == 1001){
			that.tui.TongjiLive(1, uni.getStorageSync('room_id'))
		}
		if (options.scene == 1007 || options.scene == 1008 || options.scene == 1044) {
			livePlayer.getShareParams().then(res => {
				console.log(res.custom_params.zhibo)
				if(res.custom_params.zhibo==1){
					uni.setStorageSync('refCode', res.custom_params.inviter_code)
					uni.setStorageSync('lookLive', 1)
					uni.setStorageSync('room_id', res.room_id)
					uni.setStorageSync('share_openid', res.share_openid)
					if(!this.tui.isLogin()){
						this.tui.wetLogin(1,res.room_id)
					}else{
						that.tui.TongjiLive(1, uni.getStorageSync('room_id'))
						
						return
						setTimeout(() => {
							console.log('阿斯达啊打的 打的s')
						    livePlayer.getLiveStatus({ room_id:res.room_id })
						        .then(res => {
						            // 101: 直播中, 102: 未开始, 103: 已结束, 104: 禁播, 105: 暂停中, 106: 异常，107：已过期 
						            const liveStatus = res.liveStatus
									if(liveStatus==101){
										that.tui.TongjiLive(1, uni.getStorageSync('room_id'))
									}
						            console.log('get live status', liveStatus)
						        })
						        .catch(err => {
						            console.log('get live status', err)
						        })
						}, 2000)
					}
					
				}
				console.log('get room id', res.room_id) // 房间号
				console.log('get openid', res.openid) // 用户openid
				console.log('get share openid', res.share_openid) // 分享者openid，分享卡片进入场景才有
				console.log('get custom params', res.custom_params) // 开发者在跳转进入直播间页面时，页面路径上携带的自定义参数，这里传回给开发者
			}).catch(err => {
				console.log('get share params', err)
			})
			
			
			// 往后间隔1分钟或更慢的频率去轮询获取直播状态
			
		}
		// #endif
	},
	onUnload() {
		console.log('App load');
		if(uni.getStorageSync('lookLive')==1){
			this.tui.TongjiLive(2,uni.getStorageSync('room_id'))
			// uni.setStorageSync('room_id',0)
		}
	},
	onHide: function() {
		console.log('App Hide');
		if(uni.getStorageSync('lookLive')==1){
			this.tui.TongjiLive(2,uni.getStorageSync('room_id'))
			// uni.setStorageSync('room_id',0)
		}
	}
};
</script>

<style>
/*每个页面公共css */
@import 'colorui/main.css';
@import 'colorui/icon.css';
@import 'style/FontStyle.css';
body{
	-webkit-text-size-adjust:none;
}
view,input{font-size: 26rpx;box-sizing: border-box}
.uni-center{text-align: center;}
.red{color: #eb0414;}
.font20{font-size: 22rpx;}
.bold{font-weight: bold;}
.input-class{color: #999;}
.flex,.uni-flex{display: flex;}
.flex-1,.uni-flex-item{flex: 1;}
.flex-center,.uni-flex-center{justify-content: center;}
.flex-end,.uni-flex-end{justify-content: flex-end;}
.flex-bt,.uni-flex-bt{justify-content: space-between;}
.flex-align,.uni-flex-align{align-items: center;}
.flex-line,.uni-row{display: flex;flex-wrap: wrap;align-content: space-between;}
.text_one{
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
button::after{border: none;}
/* 超出一行省略号 */
.one-omit {
	display: -webkit-box;
	-webkit-line-clamp: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	-webkit-box-orient: vertical;
}

.two-omit {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	overflow: hidden;
	text-overflow: ellipsis;
	-webkit-box-orient: vertical;
}
img{
	width: 100%;
}
.empty-box{text-align: center;padding-top: 360rpx;padding-bottom: 100rpx;}
.uni-picker-container .uni-picker-action.uni-picker-action-confirm {
	    float: right;
	    color: #f20;
	}
</style>
